/*************************************************************************
	> File Name: dealing.c
	> Author: Angel Criss
	> Mail: abbytsing@gmail.com 
	> Created Time: 四  7/10 14:12:37 2014
 ************************************************************************/

#include "head.h"
#include<errno.h>
#include <string.h>
void dealing(int sig)
{
    sigset_t unblock;
    sigemptyset(&unblock);
    if(sig>64)
    {
        printf("\ngot signal from child %d \n",sig);
        sleep(3);
    }
    else if(sig==18)
    {
        sigprocmask(SIG_UNBLOCK,&unblock,NULL);
        if(errno)
            err("handler(sigprocmask)");
    }
    else if(sig==SIGCHLD)
    {
        wait(NULL);
        printf("child's dead\n");
    }
    else
    {
        printf("\ncought signal %d (%s)\n",sig,strsignal(sig));
    happen();
    }
    /*sleep(30); // sleep a long time for waiting another singal
    在此期间发送多个安装在处理器中的信号不会排队(可能导致相同信号被忽略)
    */
    return;
}
